package com.neuedu.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.relation.RelationManager;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.neuedu.entity.Employee;
import com.neuedu.mapper.EmployeeMapper;
import com.neuedu.service.EmployeeService;
import com.neuedu.service.SchedulingService;
import jakarta.annotation.Resource;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2024-04-23
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
    @Resource
    SchedulingService schedulingService;
    @Override
    public List<Employee> list(Integer deptId, Integer week) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("deptment_id", deptId)
                .in("scheduling_id", schedulingService.getIdByWeek(week));
        RelationManager.addQueryRelations("registLevel");
        return this.mapper.selectListWithRelationsByQuery(wrapper);
    }

    @Override
    public Employee getByIdWithScheduling(Integer id) {
        RelationManager.addQueryRelations("scheduling", "registLevel");
        return this.mapper.selectOneWithRelationsById(id);
    }
}
